package pool

import (
	_ "github.com/go-sql-driver/mysql"
	"github.com/jmoiron/sqlx"
)

func NewDBConnect(name, url string, idle, maxOpen int) (*sqlx.DB, error) {
	conn, err := sqlx.Connect(name, url)
	if err != nil {
		return nil, err
	}

	conn.SetMaxIdleConns(idle)
	conn.SetMaxOpenConns(maxOpen)
	err = conn.Ping()
	return conn, err
}
